<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'basic';
$return=array();
/*******basic*******/
if($_RQ['op']=='basic'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$this->plugin_setting('basic',$postdata);
		exi('设置成功');
	}
	$return['item']=$this->plugin_setting('basic');
	$htmls=array(
		'type'=>'edit',
		'desc'=>'参数设置',
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'基本信息',
				'list'=>array(
					array('type'=>'switch','title'=>'多语言开启状态','name'=>'isopen'),
					array('type'=>'checkbox','title'=>'开启店铺语言','name'=>'is_langs','options'=>'langs','help'=>'默认语言是简体中文'),
				)
			),
			array(
				'title'=>'翻译Api配置',
				'list'=>array(
					array('type'=>'switch','title'=>'Api翻译功能?','name'=>'isopenapi'),
					array('type'=>'switch','title'=>'默认语言翻译?','name'=>'isopenup'),
					array('type'=>'title','title'=>'Api翻译引擎'),
					array('type'=>'string','title'=>'DEEP翻译Api Key','name'=>'deep_key','help'=>'Api Key，获取地址：https://rapidapi.com/gatzuma/api/deep-translate1/'),
					array('type'=>'string','title'=>'Google翻译Api Key','name'=>'google_key','help'=>'Api Key，获取地址：https://rapidapi.com/googlecloud/api/google-translate1/'),
				)
			),
		),
	);
	$return['htmls']=$htmls;
	$return['langs']=$this->langs;
	exi($return);
}
if($_RQ['op']=='upfanyi'){
	$postdata=get_postdata();
	$en=$_RQ['en'];
	$fanyidata=$postdata['fanyidata'];
	if(!$fanyidata){
		exi('翻译源内容不能为空！','error');
	}
	$res=$this->model('model')->upfanyi($fanyidata,$en);
	foreach($res as $k=>$rv){
		if($postdata['diy']){
			$postdata['diy'][$en.$k]=$rv;
		}else{
			$postdata[$en.$k]=$rv;
		}
	}
	exi($postdata);
}
/*******basic*******/
/*******op*******/
